//go:build windows

package sys

import (
	"fmt"
	"os"
	"os/exec"
	"syscall"
)

func Daemonize(childArgs []string) (*exec.Cmd, error) {
	cmd := exec.Command(os.Args[0], childArgs...)
	cmd.Stdout = os.Stdout
	cmd.Stderr = os.Stderr
	cmd.Stdin = os.Stdin
	cmd.SysProcAttr = &syscall.SysProcAttr{
		HideWindow:    true,
		CreationFlags: 0x00000010, // CREATE_NEW_CONSOLE
	}
	err := cmd.Start()
	return cmd, err
}

type FakeSocket struct {
}

func (f *FakeSocket) Open(_ bool, _, _, _ string) bool {
	return false
}

func (f *FakeSocket) Close() {
}

func (f *FakeSocket) Send(_ []byte) (int, error) {
	return -1, fmt.Errorf("os not supported")
}
